﻿@model ConfigurationModel
@using Spotshub.Plugin.Payments.GlobalPayments.Models;
@using Nop.Web.Framework;

@{    
    //page title
    ViewBag.Title = T("Plugins.Payments.GlobalPayments.EditProfile").Text;
}

    @(Html.Telerik().Grid<>()
                    .Name("productcategories-grid")
                       .DataKeys(keys =>
                       {
                           keys.Add(x => x.Id);
                       })
                       .DataBinding(dataBinding =>
                       {
                           dataBinding.Ajax()
                               .Select("ProfileList", "Product", new { productId = Model.Id })
                               .Insert("ProfileInsert", "Product", new { productId = Model.Id })
                               .Update("ProfileUpdate", "Product")
                               .Delete("ProfileDelete", "Product");
                       })
                       .Columns(columns =>
                       {
                           columns.Bound(x => x.Category)
                               .Width(500)
                               .Centered();
                           columns.Bound(x => x.IsFeaturedProduct)
                               .Width(100)
                               .Centered();
                           columns.Bound(x => x.DisplayOrder)
                               .Width(100);
                           columns.Command(commands =>
                           {
                               commands.Edit().Text(T("Admin.Common.Edit").Text);
                               commands.Delete().Text(T("Admin.Common.Delete").Text);
                           })
                           .Width(180);
                       })
                       .ToolBar(commands => commands.Insert())
                       .ClientEvents(events => events.OnEdit("onProfileEdit"))
                       .EnableCustomBinding(true))
    
    <script type="text/javascript">
        function onProfileEdit(e) {
            $(e.form).find('#Category').data('tDropDownList').select(function (dataItem) {
                return dataItem.Value == e.dataItem['CategoryId'];
            });
        }
    </script>